package com.ljcalc.business.components;

import java.util.ArrayList;

import junit.framework.TestCase;

public class CombinationTest extends TestCase {

	public void setUp() throws Exception{
		
	}
	
	public void tearDown() throws Exception{
		
	}
	
	public void testInserNumber() throws Exception{
		Combination comb = new Combination();
		comb.insertNumber(100);
		comb.insertNumber(77);
		comb.insertNumber(12);
		comb.insertNumber(123);
		comb.insertNumber(432);
		comb.insertNumber(1);
		comb.insertNumber(12);
		assertEquals(false, comb.isFull());
		comb.insertNumber(54);
		assertEquals(true, comb.isFull());
		comb.insertNumber(23);
	}
	
	public void testExtraTry(){
		Combination comb = new Combination();
		int[] test = new int[]{1,2,3,4,4,5,6,7,8,9};
		int testIndex = 0;
		for(int i=0; i<7; i++){
			if(!comb.insertNumber(test[testIndex])){
				i=i-1;
			}
			testIndex ++;
		}
		assertEquals(true, comb.isFull());
	}
	
	public void testContains(){
		ArrayList<Combination> list = new ArrayList<Combination>();
		Combination comb1 = new Combination();
		long[] test1 = new long[]{1,2,3,4,5,6,7};
		comb1.setComb(test1);
		
		Combination comb2 = new Combination();
		long[] test2 = new long[]{1,2,3,4,5,6,8};
		comb2.setComb(test2);
		
		Combination comb3 = new Combination();
		long[] test3 = new long[]{1,2,3,4,5,6,9};
		comb3.setComb(test3);
		
		Combination comb4 = new Combination();
		long[] test4 = new long[]{1,2,3,4,5,6,7};
		comb4.setComb(test4);
		
		list.add(comb1);
		list.add(comb2);
		
		assertEquals(true, list.contains(comb4));
		assertEquals(false, list.contains(comb3));
		System.out.println(comb4);
	}
}
